/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ove.openmath.jome.model;

/**
 *
 * @author Mr.Sam
 */
import java.util.*;
import fr.ove.openmath.jome.model.*;
import fr.ove.openmath.jome.model.events.ModelEvent;

/**
* The substitution model of the symbol, with the same name, in the Mfd2 cd.
*
* @author © 1999 DIRAT Laurent
* @version 2.0 28/10/1999
*/
public class Mfd2Substitution extends Function {
    /** 
    * Inserts the instance in the formula tree structure.<BR>
    * @param current the position in the formula tree where the operator is to be insert.
    * @return the new current position int hte formula tree.
    */
    public FormulaTreeStructure insert(FormulaTreeStructure current) {
        // Surchage le la méthode insert(..) car on ne veut pas qu'un template soit inséré,
        // mais une instance de SubstitutionElement.
        // C'est en qques sorte SubstitutionElement qui se charge de l'aspet 2n-aire de la chose.
        
        // Donc insertion classique...
        current = super.insert(current);
        // ...mais à la place du template, on met un SubstitutionElement
        return (new Mfd2SubstitutionElement()).insert(current);
    }
    
    /**
    * Adds a new SubstitutionElement to the end of the list.
    * Returns the new element.
    */
    public FormulaTreeStructure addElement() {
        // Pareil que pour insert, on veut un SubstitutionElement à la place d'un template
        FormulaTreeStructure current = super.addElement();
        return (new Mfd2SubstitutionElement()).insert(current);
    }
}

